-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazily setup the router in non-application tests #19080
Conversation
41b87a7
to
5843603
Compare
@rwjblue (friendly ping) can you take another look? |
5843603
to
c6226d0
Compare
7571af3
to
038471d
Compare
packages/ember/tests/routing/router_service_test/non_application_test_test.js
Outdated
Show resolved
Hide resolved
if (instance) { | ||
instance.didCreateRootView(this._toplevelView); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a cursory review, this seems somewhat unrelated to the other changes. What circumstances would have forced _setOutlets
to be called without an -application-instance:main
(IOW why is this change needed)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm RenderingTestCase
does not have -application-instance:main
registered. I guess it's just how ember internal test setup, not having any real impact on user's test. Should we use another base test case class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think its fine but I'd like to make an explicit test case so we don't accidentally make rendering test case have one and remove the guard. Specifically, I think tests that use a custom resolver (e.g. ember-engines's engineResolverFor
) will have this exact issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a RouterNonApplicationTestCase
Thanks for pushing this forward @xg-wang! |
24deea5
to
bf8311e
Compare
During non setupApplicationTests type tests, the Router being injected into service:router and service:routing does not setup automatically, during which it initializes its _routerMicrolib, etc. Public API on service:router will throw in those tests. This commit will trigger setupRouter when accessing EmberRouter via router service to avoid those errors.
bf8311e
to
cba48c5
Compare
@rwjblue the tests are passing (they failed because timeout issue before) can you take a look? |
Thanks @xg-wang! |
looks like documentation, mentioned |
@lifeart Good catch! I'm taking a look at how to update that page |
PR emberjs#19080 fixed the issue where accessing public router service throwing error, however, the PR did not support LinkTo component which uses the internal -routing service. This PR adds similar lazy setup to -routing.router.
This assertion is no longer valid because emberjs/ember.js#19080 changed the behavior in Ember.js so that rendering tests can have routing enabled too
This assertion is no longer valid because emberjs/ember.js#19080 changed the behavior in Ember.js so that rendering tests can have routing enabled too
This assertion is no longer valid because emberjs/ember.js#19080 changed the behavior in Ember.js so that rendering tests can have routing enabled too
PR emberjs#19080 fixed the issue where accessing public router service throwing error, however, the PR did not support LinkTo component which uses the internal -routing service. This PR adds similar lazy setup to -routing.router.
During non setupApplicationTests type tests, the Router being injected
into service:router and service:routing does not start routing, in which
it initializes its _routerMicrolib. Public API on service:router will
throw in those tests.
This commit will trigger startRouting on router, in non application
tests the router service should just work.
Original PR: #17557
I cannot reopen bc force pushed the branch...
This PR is created with rebase and few changes:
setupRouter
(the semantics are a bit different,startRouting
will do an initial transition which we don't necessarily want)non_application_test.js
tonon_application_test_test.js
(because testing usages in tests 😸)